/*
* @Author: Marte
* @Date:   2018-11-01 14:32:12
* @Last Modified by:   Marte
* @Last Modified time: 2018-11-01 15:57:33
*/

const UserDao = require("../dao/user/user_dao.js");
const UserService = {
    register(req,res,next){
        //从请求中获取注册用户的用户名 密码
        const {username,password}=req.body;
        // const {username,password}=req.body;
        //发送到数据访问层
        UserDao.save({username,password})
               .then((data)=>{
                console.log(data);
                res.json({res_code:1,res_error:"",res_body:{status:1,message:"success",data:{username:data.username}}})
               })
               .catch((err)=>{
                console.log(err);
                res.json({res_code:0,res_error:"",res_body:{status:0,message:"failed"+err,data}})
               });

    },
};
module.exports = UserService;

